<!DOCTYPE html>
<html lang="en"  xmlns:shiro="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - FooTable</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link th:href="@{/asserts/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/asserts/css/font-awesome.min.css}" rel="stylesheet">
    <link th:href="@{/asserts/css/plugins/footable/footable.core.css}" rel="stylesheet">

    <link th:href="@{/asserts/css/animate.min.css}" rel="stylesheet">
    <link th:href="@{/asserts/css/style.min.css}" rel="stylesheet">
    <link th:href="@{/asserts/css/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>企业基础信息</h5>
                    <div class="ibox-tools">
                        <a href="javascript:history.back(-1)">返回</a>
                    </div>
                </div>
                <div class="ibox-content ">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="col-sm-10 mt-4">
                                <label class="col-sm-2 my-font-bold">单位名称</label>
                                <div class="col-sm-2">
                                    [[${orgBaseInfo.unitname}]]
                                </div>

                                <label class="col-sm-2 my-font-bold">境内外标志</label>
                                <div class="col-sm-2">
                                    [[${orgBaseInfo.domainName}]]
                                </div>

                                <label class="col-sm-2 my-font-bold">单位类型</label>
                                <div class="col-sm-2">
                                    [[${orgBaseInfo.unittypeName}]]
                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="row">
                        <br>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>股权结构信息</h5>
                </div>
                <div class="ibox-content">
                    <a class="btn btn-warning  btn-sm badge-pill mb-1" href="javascript:goAdd()"><i
                            class="fa fa-plus"> </i> [[#{message.add}]]</a>
                    <div class="table-responsive">
                        <table id="table">
                        </table>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/asserts/js/jquery.min.js}"></script>
<script th:src="@{/asserts/js/bootstrap.min.js}"></script>
<script th:src="@{/asserts/js/plugins/footable/footable.all.min.js}"></script>
<script th:src="@{/asserts/js/content.min.js}"></script>
<script th:src="@{/asserts/js/bootstrap-table/bootstrap-table.min.js}"></script>
<script th:src="@{/asserts/js/bootstrap-table/locale/bootstrap-table-zh-CN.js}"></script>

<script th:replace="common/myJs::myCommonJs"></script>
<script>
    $(function () {
        createTable();
    });

    function resetTable() {
        createTable()
    }

    function createTable() {
        let url = '[[@{/stock/list}]]'
        let orgId = '[[${orgBaseInfo.id}]]'
        $("#table").bootstrapTable('destroy');
        $("#table").bootstrapTable({
            url: url,        //请求后台的URL（*）
            method: 'post',                      //请求方式（*）
            contentType: "application/x-www-form-urlencoded",
            pagination: true,                   //是否显示分页（*）
            cache: false,
            pageSize: 10,//每页一条数据
            striped: true,  //表格显示条纹
            dataField: "list",
            queryParamsType: "undefined",
            queryParams: function queryParams(params) {   //设置查询参数
                var param = {
                    pageNumber: params.pageNumber,
                    pageSize: params.pageSize,
                    orgId:orgId
                };
                return param;
            },
            sidePagination: 'server',
            pageNumber: 1,
            columns: [{
                field: "id",
                visible: false
            }, {
                field: "shareholdername",
                title: "股东名称"
            }, {
                field: "nationalityName",
                title: "股东国别"
            }, {
                field: "natureName",
                title: "股东性质"
            }, {
                field: "organizationName",
                title: "股东组织形式"
            }, {
                field: "proportion",
                title: "股权比例"
            }, {
                field: "cz",
                title: "操作",
                width: "20%",
                formatter: function (value, row) {
                    var editHtml = '<a href="javascript:;" class="btn btn-success edit"><i class="fa fa-pencil"> </i> 编辑</a>&nbsp;';
                    var delHtml = '<a href="javascript:;" class="btn btn-danger del"><i class="fa fa-trash"> </i> 删除</a>&nbsp;';
                    var buttonhtml = editHtml+delHtml;
                    return buttonhtml;
                },
                events: {
                    'click .edit': function (e, value, row, index) {
                        var id = row.id;
                        location.href = 'goedit?id=' + id;
                    },
                    'click .del': function (e, value, row, index) {
                        var id = row.id;
                        var url = 'delete';

                        $('#confirmModal').modal("show");
                        $("#confirmDelete").click(function () {
                            $.ajax({
                                url: url,
                                data: 'id=' + id,
                                type: "post",
                                success: function (data) {
                                    createTable();
                                }
                            });
                            $('#confirmModal').modal("hide");
                        });
                    },

                    'click .audit': function (e, value, row, index) {
                        var id = row.id;
                        location.href = 'goedit?id=' + id;
                    },

                }
                }]
        });
    }


    function goAdd() {
        let url = '[[@{/stock/goadd}]]';
        let orgId = '[[${orgBaseInfo.id}]]';
        location.href = url + "?orgId=" +orgId;
    }
</script>
</body>

</html>

<div th:fragment="showConfirm" xmlns:th="http://www.w3.org/1999/xhtml">
    <div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="myModalLabel">确认删除</h4>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                </div>
                <div class="modal-body">
                    <button type="button" class="btn btn-default cancel" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary del" id="confirmDelete">确认删除</button></div>

            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>